<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<div class="intern_add" style="display: block;">
    <p>编辑实习经历</p>
        <table>
            <tr>
                <td colspan="2">
                    <div class="layui-inline">
                        <label class="layui-form-label">公司名称</label>
                        <div class="layui-input-inline">
                            <input type="text" id="companyName" class="layui-input" placeholder="请填写公司名称"
                                   value="${intern.companyName}" style="width: 490px">
                        </div>
                    </div>
                </td>
                <td></td>
            <tr>
                <td>
                    <div class="layui-inline">
                        <label class="layui-form-label">公司行业</label>
                        <div class="layui-input-inline">
                            <input type="text" id="companyIndustry" class="layui-input" placeholder="请填写公司行业"
                                   value="${intern.companyIndustry}">
                        </div>
                    </div>
                </td>
                <td>
                    <div class="layui-inline">
                        <label class="layui-form-label">职位名称</label>
                        <div class="layui-input-inline">
                            <input type="text" id="title" class="layui-input" placeholder="请填写职位名称"
                                   value="${intern.title}">
                        </div>
                    </div>
                </td>
            </tr>

            <tr>
                <td colspan="2">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">起止日期</label>
                            <div class="layui-inline" id="test-range">
                                <div class="layui-input-inline">
                                    <input type="text" id="startDate" class="layui-input" placeholder="开始时间"
                                           value="<fmt:formatDate value="${intern.startDate}" pattern="yyyy-MM-dd"/>"
                                           style="width: 213.4px">
                                </div>
                                <div class="layui-form-mid">-</div>
                                <div class="layui-input-inline">
                                    <input type="text" id="endDate" class="layui-input" placeholder="结束时间"
                                           value="<fmt:formatDate value="${intern.endDate}" pattern="yyyy-MM-dd"/>"
                                           style="width: 213.4px">
                                </div>
                            </div>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">实习经历</label>
                        <div class="layui-input-block">
                            <textarea name="desc" id="content" placeholder="请填写工作内容（不超过500字）"
                                      class="layui-textarea">${intern.content}</textarea>
                        </div>
                    </div>
                </td>
            </tr>
        </table>

    <button class="button_save" value="${intern.id}" onclick="button_intern_save(this.value)">保存并更新</button>
    <button class="button_cancel" id="button_intern_cancel">取消</button>
</div>
<script>
    // $("#button_intern_save").click(function () {
    function button_intern_save(obj){
        let resumeId = $("#resumeId").val();
        let internId = obj;
        let companyName = $("#companyName").val();
        let companyIndustry = $("#companyIndustry").val();
        let title = $("#title").val();
        let startDate = $("#startDate").val();
        let endDate = $("#endDate").val();
        let content = $("#content").val();
        let param = "id=" + internId + "&companyName=" + companyName + "&companyIndustry=" + companyIndustry
            + "&title=" + title + "&startDate=" + startDate + "&endDate=" + endDate + "&content=" + content;
        console.log(param);
        $.post('/hire/resume/intern/update', param, function (res) {
            if (res.code == '200') {
                $("#intern_info").load("/hire/resume/intern_info", {id: resumeId});
                $("#intern_edit").hide();
                $("#intern_info").show();
            } else {
                layer.msg(res.msg);
            }
        })
    }
    // })


    $("#button_intern_cancel").click(function () {
        let resumeId = $("#resumeId").val();
        $("#intern_info").load("/hire/resume/intern_info", {id: resumeId});
        $("#intern_edit").hide();
        $("#intern_info").show();
    })
    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#startDate' //指定元素

        });
    });
    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#endDate' //指定元素

        });
    });

</script>
